//
//  ColorChangerViewController.m
//  MultiTouch
//
//  Created by iD Student on 7/11/13.
//  Copyright (c) 2013 iD Student. All rights reserved.
//

#import "ColorViewController.h"

@interface ColorViewController ()

@end

@implementation ColorViewController

@synthesize view;

- (id)init
{
    int screenWidth = [[UIScreen mainScreen]bounds].size.width;
    int screenHeight = [[UIScreen mainScreen]bounds].size.height;
    view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height)];
    view.backgroundColor = [UIColor colorWithRed:127 green:15 blue:126 alpha:1.0000];
    pickerBackground = [[UIPickerView alloc]initWithFrame:CGRectMake(0,[[UIScreen mainScreen]bounds].size.height * 2.0 / 3.0, 320, 216)];
    UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(screenWidth *  0.0625, screenHeight * 0.01094890510949, screenWidth * .14375, screenHeight * 0.08029197080292)];
    [view addSubview:backButton];
    [backButton addTarget:self action:@selector(hideView) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(screenWidth * 0.0625, screenHeight * 0.10583941605839, screenWidth * 0.875, screenHeight * 0.05656934306569)];
    label.text = [NSString stringWithFormat:@"Background Colors"];
    
	// Do any additional setup after loading the view.
    arrayOfColors = [[NSArray alloc]initWithObjects:
                     [UIColor colorWithHue:280 saturation:100 brightness:38.8141 alpha:1],
                     [UIColor colorWithHue:164 saturation:100 brightness:38.8141 alpha:1],
                     [UIColor colorWithHue:202 saturation:100 brightness:38.8141 alpha:1],
                     [UIColor colorWithHue:20 saturation:100 brightness:38.8141 alpha:1],
                     [UIColor colorWithHue:307 saturation:100 brightness:38.8141 alpha:1],
                     [UIColor colorWithHue:224 saturation:100 brightness:38.8141 alpha:1], nil];
    
    pickerBackground.delegate = self;
    pickerBackground.dataSource = self;
    
    arrayOfNames = [[NSArray alloc]initWithObjects:
                    [NSString stringWithFormat:@"Violet"],
                    [NSString stringWithFormat:@"Lime Green"],
                    [NSString stringWithFormat:@"Baby Blue"],
                    [NSString stringWithFormat:@"Red"],
                    [NSString stringWithFormat:@"Violet"],
                    [NSString stringWithFormat:@"Blue"],
                    nil];
    return self;
}

-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    return 1;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [arrayOfNames objectAtIndex:row];
}


- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component
{
    return arrayOfColors.count;
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    selectedRow = row;
}

- (void)hideView
{
    [view removeFromSuperview];
}

@end
